let app = getApp();
Page({
  data: {
    data: [], //数据
    house_type: 0, //户型
    house_style: 0, //风格
    house_area: 0, //面积
    userInfo: [],
    
    housetype_list: [{
      name: "正序"
    }, {
      name: "倒序"
    }],
    tabTxt: ['排序', '时间', '级别'], //tab文案
    tab: [true, true, true],
    navData: [{
      name: "首页",
      current: 0,
      style: 0,
      ico: 'icon-deng',
      fn: 'navJumpPage',
      id: '/pages/home/home'
    }, {
      name: "客户",
      current: 1,
      style: 0,
      ico: 'icon-guanlikehu',
      fn: 'navJumpPage',
      id: ''
    }, {
        name: "添加汇报",
      current: 0,
      style: 1,
      ico: '',
      fn: 'navJumpPage',
        id: '/pages/addReport/addReport'
    }, {
      name: "工作汇报",
      current: 0,
      style: 0,
      ico: 'icon-xiebaogao',
      fn: 'navJumpPage',
      id: '/pages/report/report'
    }, {
      name: "我的",
      current: 0,
      style: 0,
      ico: 'icon-dkw_wode',
      fn: 'navJumpPage',
      id: '/pages/salesmanMine/salesmanMine'
    }]
  },
  navJumpPage(event) {
    let url = event.currentTarget.id;
    if (url) {
      if (url === '/pages/addReport/addReport') {
        wx.navigateTo({
          url: url
        });
      } else {
        wx.redirectTo({
          url: url
        });
      }
    }
  },
  jumpClient(res){
    wx.navigateTo({
      url: '/pages/addClient/addClient?id='+res.currentTarget.id
    });
  },
  // 选项卡
  filterTab(e) {
    var data = [true, true, true],
      index = e.currentTarget.dataset.index;
    data[index] = !this.data.tab[index];
    this.setData({
      tab: data
    })
  },
  // 获取筛选项
  getFilter() {
    var self = this;

  },
  //筛选项点击操作
  filter(e) {
    var self = this,
      id = e.currentTarget.dataset.id,
      txt = e.currentTarget.dataset.txt,
      tabTxt = this.data.tabTxt;
    switch (e.currentTarget.dataset.index) {
      case '0':
        tabTxt[0] = txt;
        self.setData({
          page: 1,
          data: [],
          tab: [true, true, true],
          tabTxt: tabTxt,
          house_type: id
        });
        break;
      case '1':
        tabTxt[1] = txt;
        self.setData({
          page: 1,
          data: [],
          tab: [true, true, true],
          tabTxt: tabTxt,
          house_style: id
        });
        break;
      case '2':
        tabTxt[2] = txt;
        self.setData({
          page: 1,
          data: [],
          tab: [true, true, true],
          tabTxt: tabTxt,
          house_area: id
        });
        break;
    }
    //数据筛选
    self.getData();
  },
  onLoad(options) {
    let that = this;
    wx.getStorage({
      key:'openid',
      success(res){
        that.setData({
          openid:res.data
        });
        that.loadList();
      }
    });
    wx.getStorage({
      key: 'openid',
      success(res) {
        that.setData({
          openid: res.data
        });
        that.loadList();
      }
    })
  },
  loadList(){
    let that = this;
    app.get('YeWuYuankeHu',{
      action: 'getkehubyopenid',
      openid:that.data.openid
    }).then((res)=>{
      that.setData({
        userInfo:res
      })
    })
  }
})